package com.kinyx.framework.db.daos;

import org.junit.Test;

import com.kinyx.framework.db.configs.DBConfigsHelper;
import com.kinyx.framework.enums.impl.UsingStatus;
import com.kinyx.test.entities.impl.DemoEntity;

public abstract class JDBCDao_Tester_save_remove extends SUPER {

	@Test
	public void test_save_1() {
		this.logger.debug("test_save_1");
		this.logger.debug("test_save_1 -> 1、主键无值。新增数据。");
		final DemoEntity entity = new DemoEntity();
		this.dao.save(null, entity);
	}

	@Test
	public void test_save_2() {
		this.logger.debug("test_save_2_1");
		this.logger.debug("test_save_2_1 -> 2、主键有值。按照主键查表。");
		this.logger.debug("test_save_2_1 -> 2.1、无数据。新增数据。");
		final DemoEntity entity = new DemoEntity();
		entity.setId(DBConfigsHelper.getDBConfigs(this.dao.getKey()).getPKGenerator().id(32));
		this.dao.save(null, entity);

		this.logger.debug("test_save_2_2");
		this.logger.debug("test_save_2_2 -> 2、主键有值。按照主键查表。");
		this.logger.debug("test_save_2_2 -> 2.2、有数据。校验是否有字段修改。");
		this.logger.debug("test_save_2_2 -> 2.2.1、无字段修改。忽略。");
		this.dao.save(null, entity);

		this.logger.debug("test_save_2_3");
		this.logger.debug("test_save_2_3 -> 2、主键有值。按照主键查表。");
		this.logger.debug("test_save_2_3 -> 2.2、有数据。校验是否有字段修改。");
		this.logger.debug("test_save_2_3 -> 2.2.2、有字段修改。更新数据。");
		entity.setUsingStatus(UsingStatus.DEPRECATED);
		this.dao.save(null, entity);
	}

	@Test
	public void test_delete_1() {
		this.logger.debug("test_delete_1");
		this.logger.debug("test_delete_1 -> 1、主键无值。忽略。");
		final DemoEntity entity = new DemoEntity();
		this.dao.remove(null, entity);
	}

	@Test
	public void test_delete_2() {
		this.logger.debug("test_delete_2");
		this.logger.debug("test_delete_2 -> 2、主键有值。按照主键查表。");
		this.logger.debug("test_delete_2 -> 2.1、无数据。忽略。");
		final DemoEntity entity = new DemoEntity();
		entity.setId(DBConfigsHelper.getDBConfigs(this.dao.getKey()).getPKGenerator().id(32));
		this.dao.remove(null, entity);
	}

	@Test
	public void test_delete_3() {
		this.logger.debug("test_delete_3");
		this.logger.debug("test_delete_3 -> 先存一条数据");
		final DemoEntity entity = new DemoEntity();
		this.dao.save(null, entity);
		this.logger.debug("test_delete_3 -> 2、主键有值。按照主键查表。");
		this.logger.debug("test_delete_3 -> 2.2、有数据。删除数据。");
		this.dao.remove(null, entity);
	}

}
